(function ($) {
    myAlert = function (message, title, callback) {
        if (title == null) title = "Alert";
        $("#infoModal .modal-body > div").html(message);
        $("#infoModal").modal("show");
        $('#infoModal').unbind("hidden.bs.modal");
        if (callback) {
            $('#infoModal').on('hidden.bs.modal', function () {
                callback();
            });
        }
    };

    myConfirm = function (message, title, callback, cancle_callback, width) {
        if (title == null) title = "确认信息";
        if (width == undefined || width == null) width = "300px";
        $("#confirmModal .modal-dialog").width(width);
        $("#confirmModal .modal-header .modal-title").html(title);
        $("#confirmModal .modal-body > div").html(message);
        $("#confirmModal").modal("show");
        $('#confirmModal').unbind("hidden.bs.modal");
        $(".confirmOk").unbind("click").on("click", function () {
            $('#confirmModal').modal("hide");
            $('#confirmModal').on('hidden.bs.modal', function () {
                if (callback) callback();
            });
        });
        $(".confirmCancel").unbind("click").on("click", function () {
            $('#confirmModal').on('hidden.bs.modal', function () {
                if (cancle_callback) cancle_callback();
            });
        });
    };
})(jQuery);

/*function GetRequest(url) {
    //var url = location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        //console.log(strs)
        for (var i = 0; i < strs.length; i++) {
            theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
        }
    }
    return theRequest;
}*/

//全局的ajax访问，处理ajax清求时异常【先处理自身访问，再处理全局】
/*$.ajaxSetup({
    contentType: "application/x-www-form-urlencoded;charset=utf-8",
    complete: function (XMLHttpRequest, textStatus) {
        //通过XMLHttpRequest取得响应结果
        var res = XMLHttpRequest.responseText;
        try {
            var jsonData = JSON.parse(res);
            if (jsonData.code == -1) {
                //如果超时就处理 ，指定要跳转的页面(比如登陆页)
                myAlert("<font color=\"red\">"+jsonData.msg+"</font>", null, function () {
                    window.location.href = "/site";
                });
            } else if (jsonData.code == 0) {
                //其他的异常情况,给个提示。
                alert(jsonData.msg);
            } else {
                //正常情况就不统一处理了
            }
        } catch (e) {
        }
    }
});*/
